package com.tbrain.secretFriend.service;
import java.util.*;
import java.sql.*;

import com.tbrain.secretFriend.model.Group;

public class GroupService {
	private Connection conn;

	public GroupService(Connection c){
		conn = c;
	}

	public List getGroups(){
		List list = new ArrayList();

		try {
			PreparedStatement p = conn.prepareStatement("SELECT GroupId,Description FROM SF_GROUP");
			ResultSet r = p.executeQuery();
			while(r.next()){
				Group g = new Group();
				g.setGroupId(r.getInt(1));
				g.setDescription(r.getString(2));
				list.add(g);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return list;
	}
}

